function t(n) {
    a.showLoading("正在提交数据"), wx.request({
        url: o.globalData.host + "/lotto/v1/sponsor/apply",
        method: "POST",
        data: {
            access_token: a.getStorage("accessToken"),
            name: n.data.name,
            phone: n.data.phone,
            wx_no: n.data.wx_no,
            company: n.data.company,
            comment: n.data.comment
        },
        success: function(o) {
            a.hideLoading(), -500 != o.data.sta ? 0 == o.data.sta ? (a.showToast("保存信息成功"), 
            wx.navigateBack({
                delta: 1
            })) : a.showModelTips("保存信息失败，原因:" + o.data.msg) : a.login(function() {
                t(n);
            });
        },
        fail: function(t) {
            a.hideLoading(), a.showModelTips("请求超时，请重试");
        }
    });
}

var a = require("../../utils/util.js"), n = require("../../tmp/tmp.js"), o = getApp();

Page({
    data: {
        name: "",
        phone: ""
    },
    onLoad: function(t) {
        n.wxLogin(this);
    },
    onShow: function() {
        a.checkSession(this);
    },
    inputName: function(t) {
        this.setData({
            name: t.detail.value
        });
    },
    inputPhone: function(t) {
        this.setData({
            phone: t.detail.value
        });
    },
    inputWx: function(t) {
        this.setData({
            wx_no: t.detail.value
        });
    },
    inputCompany: function(t) {
        this.setData({
            company: t.detail.value
        });
    },
    inputComment: function(t) {
        this.setData({
            comment: t.detail.value
        });
    },
    login1: function(t) {
        if (!(t.detail.errMsg.indexOf("fail") > 0)) {
            var n = this;
            a.showLoading("正在登录..."), a.buttonLogin(function() {
                a.hideLoading(), n.setData({
                    hasUserInfo: !0
                }), n.sponsor(t);
            }, function() {
                a.hideLoading();
            }, t.detail);
        }
    },
    sponsor: function() {
        var n = this.data.name;
        if (n || "" != n.trim()) {
            var o = this.data.phone;
            o || "" != o.trim() ? t(this) : a.showModelTips("请输入手机");
        } else a.showModelTips("请输入姓名");
    }
});